<?php

class Front_Form_Auth_Registration extends Zend_Form
{

    public function init()
    {
        $firstname = $this->createElement('text', 'firstname');
		$firstname->setLabel('Votre Prénom :*')
				  ->setRequired(true)
				  ->addFilter('StripTags')
				  ->addFilter('StringTrim')
				  ->addValidator('NotEmpty')
				  ->addValidator('StringLength', false, 3, 20)
				  ->setDescription("");
		
		$lastname = $this->createElement('text', 'lastname');
		$lastname->setLabel('Votre Nom :*')
				 ->setRequired(true);
		
		$email = $this->createElement('text', 'email');
		$email->setLabel('Email: *')
			  ->setRequired(true)
			  ->addFilter('StripTags')
			  ->addFilter('StringTrim')
			  ->addValidator('NotEmpty')
			  ->addValidator('EmailAddress')
			  ->setDescription("");
		
		$username = $this->createElement('text', 'username');
		$username->setLabel('Username: *')
				 ->setRequired(true)
				 ->addFilter('StringTrim')
				 ->addValidator('NotEmpty');
		
		$password = $this->createElement('password', 'password');
		$password->setLabel('Mot de passe: *')
				 ->setRequired(true)
				 ->addFilter('StringTrim')
				 ->addValidator('NotEmpty');
		
		$confirmPassword = $this->createElement('password', 'confirmPassword');
		$confirmPassword->setLabel('Retaper votre mot de pass :*')
						->setRequired(true)
						->addFilter('StringTrim')
						->addValidator('NotEmpty');
						$confirmPassword->setDescription("");
						
		$locale = Zend_Registry::get('Zend_Locale');
		$pays = new  Zend_Form_Element_Select('pays');
		$pays ->setLabel('Pays')
		->addMultiOptions(Zend_Locale::getTranslationList('territory', $locale, 2))
		->addValidator('NotEmpty');
		
		$pubKey = '6Lfc-9gSAAAAAAcG5wv0k6SNh96XD4YAtAO5WLqd ';
		$privKey = '6Lfc-9gSAAAAAEGXzka3d1EScKJbtNu0ZjF1KnGG ';
		$recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey);
		$adapter = new Zend_Captcha_ReCaptcha();
		$adapter->setService($recaptcha);
		$captcha = new Zend_Form_Element_Captcha('recaptcha', array( 'label' => "Captcha", 'captcha' => $adapter));
		$captcha->removeDecorator('label')->removeDecorator('errors');
		
		
// 		$register = $this->createElement('submit', 'submit');
// 		$register->setLabel('Sauvegarder')
// 				 ->setIgnore(true);
		
		$this->addElements(array(
				$firstname, $lastname, $email, $username, $password, $confirmPassword, $pays, $recaptcha
		));
		
		$this->setDecorators( array( array('ViewScript', array('viewScript' => 'auth/register-form.phtml'))));
    }


}

